//
//  NumberPadCollectionView.swift
//  E-CycleForShop
//
//  Created by enghou on 17/4/21.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit

class NumberPadCollectionView: UIView {

    private var collections : Array<NumberPadView> = []
    override init(frame: CGRect) {
        super.init(frame: frame)
        let imageView = UIImageView.init()
        imageView.frame = self.bounds
        imageView.image = UIImage.load(name: "ic_jishuqi")
        self.addSubview(imageView)
        
        for i in 0 ..< 9 {
            let number = NumberPadView.init(frame: CGRect.init(x: frame.width / 9 * CGFloat(i), y: 0, width: frame.width / 9, height: frame.size.height))
            self.addSubview(number)
            collections.append(number)
        }
    }
    
    //滚动到指定的数字处
    func scroll(number : Int) -> Void {
        let bit = NumberToString.digit(number: number, radix: 10) + 1
        if bit > 0 {
            for i in 1...bit {
                let collection = collections[9-i]
                let num = NumberToString.num(number: number, idx: i)
                collection.scrool(destinatedNum: num)
            }
        }
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
//    let attribute = UICollectionViewLayout.
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
